package cn.yangyanzhao.springboot.benchtest.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.WebAsyncTask;

/**
 * SpringBoot压力测试
 *
 * @author adairs adairs@yeah.net
 * @date 2020-05-22
 */
@RestController
public class BenchTestController {

    /**
     * 未使用HTTP异步的接口
     */
    @GetMapping("/testNoSync")
    public String testNoSync() {
        return "NoSync";
    }


    /**
     * 使用HTTP异步的接口
     */
    @GetMapping("/testSync")
    public WebAsyncTask<String> testSync() {
        return new WebAsyncTask(() -> {
            return "Sync";
        });
    }

}
